{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [],
   "source": [
    "f = open(\"gt.txt\", 'w')\n",
    "ll=['label_bs','label_ssh','label_hsj','label_jyj']\n",
    "for k in ll:\n",
    "    \n",
    "    xml_filelist=os.listdir(\"img/for_EAST/\"+k) #xml 있는 위치(\"JU\"J|O\"식으로 라벨링된)\n",
    "    xml_filelist.sort()\n",
    "    check=0\n",
    "    for file_name in xml_filelist:\n",
    "\n",
    "        file_name_=file_name.split(\".\")[0]\n",
    "        #f.write(\"test/\"+file_name_+\".jpg \")\n",
    "        if file_name.endswith(\"xml\") is not True:\n",
    "            continue\n",
    "        doc = ET.parse(\"img/for_EAST/\"+k+\"/\"+file_name)\n",
    "        root = doc.getroot()\n",
    "        object_tag = root.findall(\"object\")\n",
    "        #if len(object_tag)\n",
    "        for i, obj in enumerate(object_tag):\n",
    "            check+=1\n",
    "            label = obj.findtext(\"name\")\n",
    "            f.write(\"test/\"+file_name_+\"_\"+str(check)+\".jpg\"+\" \"+label+\"\\n\")\n",
    "\n",
    "        check=0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
